package com.fangshi.viewmodels

import com.fangshi.api.Area as ApiArea
import com.fangshi.api.Record as ApiRecord
import com.fangshi.api.Garage as ApiGarage
import com.fangshi.api.RecordWrapper as ApiRecordWrapper

class Garage(private val _garageId: String?, val garageName: String?, var carCount: Int) {

    val garageId: String?
        get() = _garageId
    val carCountDescribe: String
        get() = carCount.toString() + "辆车"

    constructor (g: ApiGarage) : this(g.id, g.name, g.carCount)
}

class Area(a: ApiArea) {
    val areaName = a.areaName
    val garages: List<Garage> = a.garages.map { Garage(it) }
}

class Record(r: ApiRecord) {
    val carNo = r.carNo
    val garageId = r.garageId
    val goInTime = r.goInTime
    val goOutTime = r.goOutTime
    val actualResidenceTime = r.actualResidenceTime
}

class RecordWrapper(w: ApiRecordWrapper) {
    val total = w.total
    val rows = w.rows.map { r -> Record(r) }
}